<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/5
 * Time: 16:39
 */

namespace app\admin\controller;
use think\Exception;
use think\Loader;
use app\admin\Controller;
use app\common\model\UserAuth as uaModel;

class UserAuth extends Controller
{

    public function index () {
        if ($this->request->method() == "GET") {
            $keyword = $this->request->param('keyword');
            $where = [
                'ua.is_del' => 0,
            ];
            if ($keyword){
                    $where['ua.nickname'] = ['like', '%' .$keyword . '%'];
                    $where['ua.phone'] = ['like', '%' . $keyword . '%'];
                    $where['ua.user_id'] = ['like', '%' .$keyword . '%'];
                    $where['ua.id'] = ['like', '%' . $keyword . '%'];
            }

            $model = new uaModel();

            $list = $model->getUserList($where, "ua.*", $this->request, $keyword);

            $this->view->assign('list', $list);
            $this->view->assign("count", $list->total());
            $this->view->assign("page", $list->render());
            $this->view->assign('numPerPage', $list->listRows());
        }
        return $this->view->fetch();

    }

    public function detail(){
        if ($this->request->method() == "GET") {
            if ($this->request->method()) {
                $id = $this->request->param('id');

                $where = [
                    'ua.id' => $id,
                ];
                $filed = "*";
                $plModel = new uaModel();
                $data = $plModel->getUserInfo($where, $filed);

                if ($data) {
                    $where = [
                        'user_id' => $data['user_id'],
                    ];
                    $field = "*";
                    $list = $plModel->getUserCarInfoList($where, $field, $this->request);

                    $this->view->assign('list', $list);
                    $this->view->assign('count', count($list));

                }
                $this->view->assign('vo', $data);
            }

        }

        return $this->view->fetch();
    }
}